<script>
/*

This file is part of Ext JS 4

Copyright (c) 2011 Sencha Inc

Contact:  http://www.sencha.com/contact

Commercial Usage
Licensees holding valid commercial licenses may use this file in accordance with the Commercial Software License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Sencha.

If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.

*/

var BASE_URL = '<?php echo base_url() ?>' + 'index.php/';
var BASE_PATH = '<?php echo base_url() ?>';
var BASE_ICONS = '<?php echo base_url() ?>' + 'assets/icons/';
var BASE_UX = '<?php echo base_url() ?>' + 'js/ext/ux';

Ext.Loader.setConfig({enabled: true});

Ext.Loader.setPath('Ext.ux', BASE_UX);
Ext.require([
    'Ext.grid.*',
    'Ext.data.*',
    'Ext.util.*',
    'Ext.toolbar.Paging',
    'Ext.ux.PreviewPlugin',
    'Ext.ModelManager',
    'Ext.tip.QuickTipManager'
]);

Ext.onReady(function(){

    var urlApp = '<?php echo base_url() ?>' + 'index.php/';


    Ext.define('data_model', {
        extend: 'Ext.data.Model',
        fields: [
            'NIM','NAMA','PRODI','TEMPAT_PPL'
        ]
    });

    // create the Data Store
    var store = Ext.create('Ext.data.Store', {
        pageSize: 15,
        model: 'data_model',
        proxy: {
            // load using script tags for cross domain, if the data in on the same domain as
            // this page, an HttpProxy would be better
            type: 'ajax',
	        headers: { 'Content-Type': 'application/json; charset=UTF-8' },
            api: {
                read: urlApp + 'sima_bimbingan/bimbinganControllerSima/viewMahasiswaPPLext/' + '<?php echo $id_angkatan ?>'
            },
            reader: {
                type: 'json',
		        successProperty: 'success',
		        root: 'data',
		        messageProperty: 'message',
                totalProperty: 'results'
            },
            listeners: {
                exception: function(proxy, response, operation){
                    Ext.MessageBox.show({
                        title: 'REMOTE EXCEPTION',
                        msg: operation.getError(),
                        icon: Ext.MessageBox.ERROR,
                        buttons: Ext.Msg.OK
                    });
                }
		    }
        }
    });

     function linkDetail(val){
        var tempku = val;
        return '<a href="<?php echo base_url();?>sima/detailppl/'+tempku+'.html">'+val+'</a>';
    }

    var grid = Ext.create('Ext.grid.Panel', {
        width: 700,
        height: 430,
        title: 'MAHASISWA BIMBINGAN',
        store: store,
        disableSelection: true,
        loadMask: true,
        // grid columns
        columns:[
          new Ext.grid.RowNumberer(),
          {
            text: "NIM",
            dataIndex: 'NIM',
            width: 100,
            sortable: false,
            renderer: linkDetail
        },{
            text: "NAMA MAHASISWA",
            dataIndex: 'NAMA',
            width: 150,
            sortable: false
        },{
            text: "PRODI",
            dataIndex: 'PRODI',
            width: 180,
            sortable: false
        },{
            text: "TEMPAT PPL",
            dataIndex: 'TEMPAT_PPL',
            width: 245,
            sortable: false
        }
        ],
        // paging bar on the bottom
        bbar: Ext.create('Ext.PagingToolbar', {
            store: store,
            displayInfo: true,
            displayMsg: 'Data ke: {0} - {1} dari {2}',
            emptyMsg: "Data tidak tersedia"
        }),
        renderTo: 'divgrid'
    });

    // trigger the data store load
    store.loadPage(1);

    });
</script>

<div id="divgrid"></div>